# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=crosstool-ng
pkgver=1.24.0
pkgrel=0
pkgdesc="tool for building toolchains"
url="http://crosstool-ng.org/"
license="LGPL-2.1-or-later GPL-2.0-or-later CC-BY-SA-2.5"
arch="x86 x86_64 ppc64le"
depends="bash gawk bison flex automake autoconf libtool cvs sed texinfo gperf"
makedepends="ncurses-dev help2man xz gettext-dev"
subpackages="$pkgname-doc $pkgname-bash-completion:bashcomp:noarch"
source="http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-$pkgver.tar.xz"

builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	./configure --prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

bashcomp() {
	depends=""
	pkgdesc="Bash completion for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	# bash completion has it's own package
	mkdir -p "$subpkgdir"/usr/share/bash-completion/completions/
	mv "$pkgdir"/usr/share/bash-completion/completions/ct-ng \
		"$subpkgdir"/usr/share/bash-completion/completions/$pkgname
}

sha512sums="89b8794a4184ad4928750e29712ed4f194aa1d0b93768d67ff64f30c30f1b1e165647cafc6de94d68d3ef70e50446e544dad65aa36137511a32ee7a667dddfb4  crosstool-ng-1.24.0.tar.xz"
